<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
 

<body>
    <div>
        <img src="./img/1668355376377.png" style="width: 700px; height:500px">
    </div>
    <script>
        //HTMLCollection数组
        var img = document.getElementsByTagName('img')[0];
        const imgArr = ['1668355376377.png', '1668355436006.png', '1668355502598.png'];
        var count = 0;

        //只执行一次
        function fn() {
            if(count<2){
                count++;
            }else{
                count = 0;
            }
            
            img.src = './img/' + imgArr[count];
            //n! 递归(调用函数本身): 出口， 表达式
            return setTimeout(fn, 3000);
        }
        setTimeout(fn, 3000);
    </script>
</body>

</html>